package Day10练习;

//已知一个数组 arr = {19, 28, 37, 46, 50}; 用程序实现把数组中的元素值交换，
//交换后的数组 arr = {50, 46, 37, 28, 19}; 并在控制台输出交换后的数组元素。

import java.util.Scanner;

public class demo09 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr1 = new int[5];
        int[] arr2 = new int[5];
        int j = arr1.length-1;
        //遍历数组
        System.out.println("输入5个整数:");
        for (int i = 0; i < 5; i++) { //i=0,1,2,3,4
            arr1[i] = sc.nextInt();
            arr2[j] = arr1[i]; //j=4,3,2,1,0
            j--;
        }
        //打印两个数组
        System.out.print("原数组内容是:");
        for (int i = 0; i < 5; i++) {
            System.out.print(arr1[i] + " ");
        }
        System.out.print("新数组内容是:");
        for (int i = 0; i < 5; i++) {
            System.out.print(arr2[i] + " ");
        }
    }
}
